package com.culture.config.core;

import javax.validation.Valid;

import com.culture.config.common.model.ResponseData;
import com.culture.config.common.util.ResponseUtil;
import com.culture.config.model.po.RegistrationPO;
import com.culture.config.model.vo.RegistrationVO;
import com.culture.config.service.ConfigService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;
import springfox.documentation.annotations.ApiIgnore;

@Slf4j
@ApiIgnore
@RestController
@RequestMapping({"/admin"})
public class ConfigInstancesController {
    @Autowired
	private ConfigService configService;
    
    @PostMapping("/instances")
    public ResponseData<RegistrationVO> register(@RequestBody @Valid RegistrationPO param){   
        log.info("register info:",param);
        return ResponseUtil.success(this.configService.register(param));
    }

    @DeleteMapping(path = "/instances/{id}")
    public void unregister(@PathVariable String id) {
        log.info("unregister id:",id);
        this.configService.unRegister(id);
    }
}
